package 实现栈的逆序;

public class 实现栈的逆序 {

	public static void main(String[] args) {

	}

	public class ReverseStack {
		public int[] reverseStackRecursively(int[] stack, int top) {
			if (top == 0)
				return null;
			recursive(stack, 0, top - 1);
			return stack;
		}

		private void recursive(int[] stack, int start, int end) {
			if (start >= end)
				return;
			stack[start] ^= stack[end];
			stack[end] ^= stack[start];
			stack[start] ^= stack[end];
			recursive(stack, start + 1, end - 1);
		}
	}
}
